/*
 * LogoutAction.java
 *
 * Created on July 17, 2007, 1:28 AM
 */

package br.usp.poli.mfc.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
/**
 *
 * @author William
 * @version
 */

public class LogoutAction extends Action {
    
    private final static String SUCCESS = "success";

    public ActionForward execute(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        
        HttpSession session = request.getSession();
        if(session.getAttribute("usuario") != null) {
            session.removeAttribute("usuario"); // Remove as informacoes do usuario da sessao. A partir daqui ele cai no filter denovo
        }
        session.invalidate();
        return mapping.findForward(SUCCESS);
        
    }
}
